import {Util} from "@lowcode/jpaas-common-lib";

import PortalLayoutPreview from "@/views/modules/portal/core/PortalLayoutPreview";
import InsColumnDialog from '@/views/modules/portal/core/InsColumnDialog';
import InsPortalPermissionEdit from '@/views/modules/portal/core/InsPortalPermissionEdit'

import {I18Parse} from '@lowcode/jpaas-common-lib';
import portalApiLang from '../../../locales/lang/impl/portal/portalApiLang';
let lang = portalApiLang.portalApi;

//门户定义 api接口
export const InsPortalDialogApi = {};

//------------------insPortalLayout.js  搬迁过来------

/*
 *门户权限配置
 */
InsPortalDialogApi.editPermission=function(self_,portId){
    var conf = {
        pkId: portId,
        component: InsPortalPermissionEdit,
        title: I18Parse.getI18Val(lang,'permissionTitle','门户权限设计'),
        widthHeight: ['1200px', '700px']
    };
    var baseConf = {
        curVm: self_,
        data: {
            pkId: conf.pkId,
            callback: function(data) {
            }
        }
    };
    let config = Object.assign(baseConf, conf);
    Util.open(config, function(action) {
    })

};

InsPortalDialogApi.openInsCloumnDefDialog=function(config,callback){
    var baseConf= {
        component:InsColumnDialog,
        title: I18Parse.getI18Val(lang,'selColumn','选择栏目')
    };
    let conf = { ...baseConf,...config };
    Util.open(conf,function(action){
        var insColumnDefs =this.getSelect();
        if(action!='ok'){
            if(!insColumnDefs.single){
                callback(this.$parent,[]);
            }
            return;
        }
        if(callback ){
            if(!insColumnDefs.single){
                callback(this.$parent,insColumnDefs.data);
            }else if(insColumnDefs.data.length>0){
                callback(this.$parent,insColumnDefs.data[0]);
            }
        }
    });
}

InsPortalDialogApi.openInsLayoutPreview=function(config){
    var baseConf= {
        component:PortalLayoutPreview,
        title: I18Parse.getI18Val(lang,'portalPreview','门户预览')
    };
    let conf = { ...baseConf,...config };
    Util.open(conf,function(action){
        return;
    });
}



export  default InsPortalDialogApi;

